import rclpy
from .sum_service_client import SumServiceClient

def main(args=None):
    rclpy.init(args = args)
    node = SumServiceClient("SumServiceClient")
    node.send_request()                          # 发送服务请求
    while rclpy.ok():                            # ROS2系统正常运行
        rclpy.spin_once(node)                    # 循环执行一次节点
        if node.future.done():                   # 数据是否处理完成
            try:
                response = node.future.result()  # 接收服务器端的反馈数据
            except Exception as e:
                node.get_logger().info('Service call failed %r' % (e,))
            else:
                node.get_logger().info('Result of add_two_ints: for %d + %d = %d' % (node.request.a, node.request.b, response.sum))
                # 将收到的反馈信息打印输出
            break
    node.destroy_node()                          # 销毁节点对象
    rclpy.shutdown()
